home *** CD-ROM | disk | FTP | other *** search
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; TDSPCTL - Demonstrates the usage of the DSPCTLx.OBJ's ;
- ; ;
- ; (C)opyright - Budget Software Company ;
- ; ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- MODEL COMPACT
- LOCALS
- JUMPS
-
- global cpp _dspctl_init_me:far
- global cpp _dspctl_request_print:far
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; The following STRUC is passed to _dspctl_init_me
- ;
- init_dspctl STRUC
- original_int8 dd ?
- original_int16 dd ?
- original_intb dd ?
- original_intc dd ?
- original_intf dd ?
- callback dd ?
- com1_int8_bytes dw ?
- com2_int8_bytes dw ?
- com3_int8_bytes dw ?
- com4_int8_bytes dw ?
- lpt1_int8_bytes dw ?
- lpt2_int8_bytes dw ?
- lpt3_int8_bytes dw ?
- lpt4_int8_bytes dw ?
- com_port_intb db ?
- com_port_intc db ?
- indicate_bios db ?
- indicate_direct db ?
- nbr_10000ths dw ?
- ENDS
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- DATASEG
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; Create an instance of my_init_dspclt
- ;
- my_init_dspctl init_dspctl ?
- ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; Define an LPT1 data stream
- ;
- some_lpt1_data db "Here's some LPT1 data. I am going to print it 50 times.",0dh,0ah
- size_of_lpt1_data dw $ - offset some_lpt1_data
- number_of_lpt1_lines db 50
- ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; Define a COM1 data stream
- ;
- some_com1_data db "Here's some COM1 data. I am going to print it 200 times.",0dh,0ah
- size_of_com1_data dw $ - offset some_com1_data
- number_of_com1_lines db 200
-
-
- CODESEG
- startupcode
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; Place the required data into my_init_dspctl
- ;
- push ds ;
- pop es ;
- mov ax,0 ;
- mov ds,ax ;
- mov di,offset my_init_dspctl ;
- mov si,8*4 ;Get INT8 data.
- mov ax,[si] ;
- stosw ;
- mov ax,[si+2] ;
- stosw ;
- mov si,16h*4 ;Get INT16h data.
- mov ax,[si] ;
- stosw ;
- mov ax,[si+2] ;
- stosw ;
- mov ax,0 ;Don't hook intb, intc, or intf.
- mov cx,6 ;
- rep stosw ;
- mov ax,offset my_callback ;Pass far pointer to my "callback"
- stosw ; procedure.
- mov ax,@code ;
- stosw ;
- mov ax,100 ;Set each port so that 100 bytes
- mov cx,8 ; will be attempted in an int8.
- rep stosw ; (Only 1 port gets a crack at it
- ; during a given timer interrupt.)
- mov al,2 ;Indicate intb is for COM2.
- stosb ; (This isn't really necessary in
- ; this example, since I'm not
- ; hooking intb.)
- mov al,1 ;Indicate intc is for COM1.
- stosb ; (This isn't really necessary in
- ; this example, since I'm not
- ; hooking intc.)
- mov al,0ffh ;Indicate that all 8 ports should
- stosb ; use the BIOS for outputting.
- mov al,00h ;Indicate that no ports should
- stosb ; print directly to the port.
- mov ax,10h ;Indicate 10 10,000ths of a second
- stosw ; as the maximum amount of time
- ; in int8
- ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; Call the init routine.
- ;
- mov ax,@data ;
- mov ds,ax ;
- mov dx,@data ;Point DX:AX to STRUC.
- mov ax,offset my_init_dspctl ;
- call _dspctl_init_me ;Init me.
- ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; Send a stream of data for LPT1 printing.
- ;
- mov cx,size_of_lpt1_data ;CX=size of stream.
- mov bh,00001000b ;Bit 3 is for LPT1.
- mov dx,@data ;Point DX:AX to stream.
- mov ax,offset some_lpt1_data ;
- call _dspctl_request_print ;Call routine.
- dec number_of_lpt1_lines ;I'm keeping a counter of the
- ; number of times I've printed
- ; this stream.
- ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; Send a stream of data for COM1 printing.
- ;
- mov cx,size_of_com1_data ;CX=size of stream.
- mov bh,10000000b ;Bit 7 is for COM1.
- mov dx,@data ;Point DX:AX to stream.
- mov ax,offset some_com1_data ;
- call _dspctl_request_print ;Call routine.
- dec number_of_com1_lines ;I'm keeping a counter of the
- ; number of times I've printed
- ; this stream.
- ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; T and SR
- ;
- mov dx,offset end_of_pgm
- shr dx,4
- inc dx
- mov ah,31h
- mov al,0
- int 21h
- ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; This procedure is the one I indicated should be
- ; called when DSPCTLx has finished printing a stream.
- ;
- my_callback PROC NOLANGUAGE FAR
- push es ds
- mov ax,@data
- mov ds,ax
- cmp bl,4 ;BL=4->LPT1 stream is finished.
- jne @@not_lpt1 ;
- cmp number_of_lpt1_lines,0 ;I'm keeping a counter of the
- ; number of times I've printed
- ; this stream.
- je @@not_lpt1 ;If it's 0, then we're done with LPT1.
- mov cx,size_of_lpt1_data ;Otherwise, CX=size of stream.
- mov bh,00001000b ;Bit 3 indicates LPT1.
- mov dx,@data ;Point DX:AX to stream.
- mov ax,offset some_lpt1_data ;
- dec number_of_lpt1_lines ;Decrement my counter.
- call _dspctl_request_print ;Request print.
- jmp @@exit ;
- @@not_lpt1:
- cmp bl,0 ;BL=0->COM1 stream finished.
- jne @@not_com1 ;
- cmp number_of_com1_lines,0 ;I'm keeping a counter of the
- ; number of times I've printed
- ; this stream.
- je @@not_com1 ;If it's 0, then we're done with COM1.
- mov cx,size_of_com1_data ;Otherwise, CX=size of stream.
- mov bh,10000000b ;Bit 7 indicates COM1.
- mov dx,@data ;Point DX:AX to stream.
- mov ax,offset some_com1_data ;
- dec number_of_com1_lines ;Decrement my counter.
- call _dspctl_request_print ;Request print.
- @@not_com1:
- @@exit:
- pop ds es
- ret
- ENDP
- end_of_pgm label byte
-
-
-
- END
-